//
//  ViewController2.m
//  11102
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController2.h"

@interface ViewController2 ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIImage *image=[UIImage imageNamed:@"1"];
    UIImageView *imageView=[[UIImageView alloc]initWithImage:image];
    [self.scrollView addSubview:imageView];
    self.scrollView.contentSize=image.size;
    
    
    self.scrollView.maximumZoomScale=2;
    self.scrollView.minimumZoomScale=0.2;
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.scrollView.subviews[0];
// return a view that will be scaled. if delegate returns nil, nothing happens
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
